package com.beiyou.orderingsystemonweb.shop.service;

import com.beiyou.orderingsystemonweb.shop.dao.ShopDao;
import com.beiyou.orderingsystemonweb.shop.dao.ShopFoodDao;
import com.beiyou.orderingsystemonweb.shop.domain.ShopFood;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@Component
public class ShopFoodService {
    @Autowired
    ShopFoodDao shopFoodDao;
    @Autowired
    ShopDao shopDao;
    public int addShopFood(String shopId,String foodName, String foodImg,String foodPrice){
        System.out.println(shopId);
        if (shopDao.queryShopBySid(shopId)!=null){
            String shopFoodId = UUID.randomUUID().toString().replace("-","");
            ShopFood shopFood = new ShopFood();
            shopFood.setShopId(shopId);
            shopFood.setShopFoodId(shopFoodId);
            shopFood.setShopFoodImg(foodImg);
            shopFood.setShopFoodName(foodName);
            shopFood.setShopFoodPrice(foodPrice);
            shopFoodDao.addShopFood(shopFood);
        }
        return 0;
    }

    public Map queryShopFoodById(String fid){
        return shopFoodDao.queryFoodById(fid);
    }
    public void updateShopFood(String foodId,String foodName,String  foodImg,String foodPrice){
        shopFoodDao.updateShopFood(foodId,foodName,foodImg,foodPrice);
    }
}
